/*
 * This file is part of WebCL – JavaScript bindings for OpenCL
 * http://webcl.nokiaresearch.com/
 *
 * Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
 *
 * Contact: Jari Nikara  ;jari.nikara@nokia.com;
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 *
 *
 * The package is based on a published Khronos OpenCL 1.1 Specification,
 * see http://www.khronos.org/opencl/.
 *
 * OpenCL is a trademark of Apple Inc.
 */

#ifndef _WEBCLPLATFORM_H_
#define _WEBCLPLATFORM_H_

#include "WebCLCommon.h"
#include "IWebCLPlatform.h" // Generated from IWebCLPlatform.idl
#include "instance_registry.h"

#include <CL/opencl.h>


#define WEBCL_PLATFORM_CLASSNAME "WebCLPlatform"
#define WEBCL_PLATFORM_CID { 0x6ab8b8cf, 0x4d87, 0x40a0, { 0xaf, 0x8a, 0xcc, 0x0b, 0xf5, 0x25, 0x1f, 0xa3 } }
#define WEBCL_PLATFORM_CONTRACTID "@webcl.nokiaresearch.com/WebCLPlatform;1"

/** Implements IWebCLPlatform interface. */
class WebCLPlatform : public IWebCLPlatform, public WebCLCommon
{
public:
  NS_DECL_ISUPPORTS
  NS_DECL_NSISECURITYCHECKEDCOMPONENT
  NS_DECL_IWEBCLPLATFORM

  static nsresult getInstance (cl_platform_id aInternal, WebCLPlatform** aResultOut,
                               WebCL_LibCLWrapper* aLibWrapper = 0);

  WebCLPlatform ();
  cl_platform_id getInternal () { return mInternal; }

protected:
  int getTypeForInfoName (int aName);

private:
  static InstanceRegistry<cl_platform_id, WebCLPlatform*> instanceRegistry;

  ~WebCLPlatform ();

  cl_platform_id mInternal;
};

#endif //_WEBCLPLATFORM_H_
